package com.nflakes.petrol.controllers;

import com.nflakes.petrol.services.SlurperService;
import groovy.lang.GroovyClassLoader;

import java.io.File;
import java.io.IOException;

public class AbstractPetrolController {
    protected SlurperService getSlurperService(String groovyScriptFileName) throws IOException, IllegalAccessException, InstantiationException {
        GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
        Class clazz = groovyClassLoader.parseClass(new File(groovyScriptFileName));
        return (SlurperService) clazz.newInstance();
    }
}
